package olga.gorbatiuk.perdep.logger.record.comparator;

import java.util.Comparator;
import java.util.logging.Level;
import java.util.logging.Logger;
import olga.gorbatiuk.perdep.logger.exceptions.MyIllegalArgumentException;

import olga.gorbatiuk.perdep.logger.record.Record;

public class ByDateComparator implements Comparator<Record> {

    @Override
    public int compare(Record record1, Record record2) {
        if (record1 == null || record2 == null) {
            try {
                throw new MyIllegalArgumentException();
            } catch (MyIllegalArgumentException ex) {
                Logger.getLogger(ByDateComparator.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        int result = record1.getTime().compareTo(record2.getTime());
        return result;
    }

}
